package com.shanzhu.volunteer.interfaces.controller.volunteer;

import com.shanzhu.volunteer.common.component.page.TableDataInfo;
import com.shanzhu.volunteer.common.entity.Response;
import com.shanzhu.volunteer.interfaces.body.volunteer.student.StudentBody;
import com.shanzhu.volunteer.interfaces.controller.BaseController;
import com.shanzhu.volunteer.interfaces.vo.volunteer.student.StudentVo;
import com.shanzhu.volunteer.modules.volunteer.service.CeStudentService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 学生管理
 *
 * @author: ShanZhu
 * @date: 2023-03-31 16:40:29
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/college_entrance/student")
public class CeStudentController extends BaseController {

    private final CeStudentService studentService;

    /**
     * 请求学生列表
     *
     * @param studentBody 学生请求体
     * @return 学生列表
     */
    @ApiOperation(value = "请求学生列表")
    @GetMapping("/list")
    public TableDataInfo list(StudentBody studentBody) {
        startPage();
        return getDataTable(studentService.selectStudentList(studentBody));
    }

    /**
     * 添加学生
     *
     * @param studentBody 学生请求体
     * @return 结果
     */
    @ApiOperation(value = "添加学生")
    @PostMapping
    public Response<Boolean> add(@RequestBody StudentBody studentBody) {
        return studentService.addStudent(studentBody);
    }

    /**
     * 编辑学生
     *
     * @param studentBody 学生请求体
     * @return 结果
     */
    @ApiOperation(value = "编辑学生")
    @PutMapping
    public Response<Boolean> edit(@RequestBody StudentBody studentBody) {
        return studentService.editStudent(studentBody);
    }

    /**
     * 通过学生id查询学生信息
     *
     * @param studentId 学生id
     * @return 结果
     */
    @ApiOperation(value = "通过学生id查询学生信息")
    @GetMapping("/{studentId}")
    public Response<StudentVo> getInfo(@PathVariable Integer studentId) {
        return new Response<>(studentService.getStudent(studentId));
    }

    /**
     * 删除学生
     *
     * @param studentIds 角色id列表
     * @return 结果
     */
    @ApiOperation(value = "删除学生")
    @DeleteMapping("/{studentIds}")
    public Response<Boolean> remove(@PathVariable Integer[] studentIds) {
        return studentService.deleteStudentByIds(studentIds);
    }

}

  